from invidious import *
import sys

sys.path.append("..")
from src.history import History
from src.config import Config

class Plugin:

    def __init__(self, history: History=History(), config: Config=Config()) -> None:
        self.id = 0
        self.name = "New Plugin"
        self.category = "Plugin Category"
        self.query_description = ""

        self.history = history
        self.config = config
        self.invidious = Invidious(isLoggerEnabled=False)

        # True  - required parameter
        # False - optional parameter
        self.params = {
            "query"     : True,
            "another"   : False
        }

        self.flag = "-p"
        self.full_flag = "--plugin"
        self.flag_help = "simple plugin"
        self.flag_action = ""

    def get_items(self, params: dict=dict()) -> list:
        if 'query' in params.keys():
            return list()
        return list()

    def to_json(self) -> dict:
        return {
            "id"                : self.id,
            "name"              : self.name,
            "category"          : self.category,
            "query_description" : self.query_description,
            "params"            : self.params
        }

    def save_config(self):
        self.config.set_option(self.category, 'test-option', 'test-value')

